@computed fields from mixin types (with) cause column does not exist error when the model is explicitly included#2539
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a Vitest e2e test for a mixin-inherited computed field and updates the TypeScript schema generator to include computed fields from all discovered fields (including mixins) when emitting Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/e2e/orm/client-api/computed-field-nested-include.test.ts (1)
60-60: Prefer typed validation overas anyto maintain type-safety in this regression test.Line 60 suppresses compiler checks that could catch future API/schema drift. The options object should use
satisfiesto validate against the function signature while preserving flexibility with string schemas:♻️ Suggested refactor
- } as any, + } satisfies Parameters<typeof createTestClient>[1],🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/e2e/orm/client-api/computed-field-nested-include.test.ts` at line 60, The test currently uses an unsafe cast ("as any") for the options object; replace that cast with TypeScript's "satisfies" operator to validate the object against the real API parameter type (for example the parameter type of the client function under test, e.g. Parameters<typeof <clientFunction>>[0] or the exported options type from the API), so the literal keeps flexible string-schema values but still gets compile-time validation; locate the options object in computed-field-nested-include.test.ts and change the "as any" to a "satisfies <expected parameter type>" check (import or reference the appropriate function/type used by the test).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/e2e/orm/client-api/computed-field-nested-include.test.ts`:
- Line 60: The test currently uses an unsafe cast ("as any") for the options
object; replace that cast with TypeScript's "satisfies" operator to validate the
object against the real API parameter type (for example the parameter type of
the client function under test, e.g. Parameters<typeof <clientFunction>>[0] or
the exported options type from the API), so the literal keeps flexible
string-schema values but still gets compile-time validation; locate the options
object in computed-field-nested-include.test.ts and change the "as any" to a
"satisfies <expected parameter type>" check (import or reference the appropriate
function/type used by the test).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3260908e-0086-4ab1-91a3-d57d0a4b7523
📒 Files selected for processing (1)
tests/e2e/orm/client-api/computed-field-nested-include.test.ts
9e94d09 to
2abea97
Compare
0653d1d to
397146d
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/sdk/src/ts-schema-generator.ts (1)
456-456: ReuseallFieldsinstead of callinggetAllFields(dm)twice.This avoids a second recursive walk and keeps field selection logic centralized.
♻️ Suggested cleanup
- const computedFields = getAllFields(dm).filter((f) => hasAttribute(f, '@computed')); + const computedFields = allFields.filter((f) => hasAttribute(f, '@computed'));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/sdk/src/ts-schema-generator.ts` at line 456, The code calls getAllFields(dm) again when computing computedFields causing an extra recursive walk; instead reuse the existing allFields array (the variable already holding getAllFields(dm) results) and filter that for hasAttribute(f, '@computed') so computedFields = allFields.filter(f => hasAttribute(f, '@computed')); update the reference to use allFields and remove the duplicate getAllFields(dm) call.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/sdk/src/ts-schema-generator.ts`:
- Line 456: The code calls getAllFields(dm) again when computing computedFields
causing an extra recursive walk; instead reuse the existing allFields array (the
variable already holding getAllFields(dm) results) and filter that for
hasAttribute(f, '@computed') so computedFields = allFields.filter(f =>
hasAttribute(f, '@computed')); update the reference to use allFields and remove
the duplicate getAllFields(dm) call.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7231e313-2b0c-4e75-a446-41409eea847c
📒 Files selected for processing (2)
packages/sdk/src/ts-schema-generator.tstests/e2e/orm/client-api/computed-field-nested-include.test.ts
397146d to
adc753f
Compare
adc753f to
afc9d44
Compare
failing test to illustrate #2540 along with a one line fix
Summary by CodeRabbit
Tests
Bug Fix